package com.budwk.app.enterprise.services.impl;

import com.budwk.starter.common.page.PageUtil;
import com.budwk.starter.common.page.Pagination;
import com.budwk.starter.database.service.BaseServiceImpl;
import com.budwk.app.enterprise.models.AssetLiabilityCategory;
import com.budwk.app.enterprise.services.AssetLiabilityCategoryService;
import org.nutz.dao.Cnd;
import org.nutz.dao.Dao;
import org.nutz.ioc.loader.annotation.IocBean;
import org.nutz.lang.Strings;

@IocBean(args = {"refer:dao"})
public class AssetLiabilityCategoryServiceImpl extends BaseServiceImpl<AssetLiabilityCategory> implements AssetLiabilityCategoryService {
    public AssetLiabilityCategoryServiceImpl(Dao dao) {
        super(dao);
    }

    @Override
    public Pagination listByPage(AssetLiabilityCategory category) {
        Cnd cnd = Cnd.NEW();
        if (Strings.isNotBlank(category.getPageOrderName()) && Strings.isNotBlank(category.getPageOrderBy())) {
            cnd.orderBy(category.getPageOrderName(), PageUtil.getOrder(category.getPageOrderBy()));
        }
        Pagination pagination = this.listPage(category.getPageNo(), category.getPageSize(), cnd);
        return pagination;
    }
}
